package com.lagou.config;

import java.util.Arrays;
import java.util.Optional;

public enum OperationTypeEnum {
    SELECT("select","查询"),
    INSERT("insert","新增"),
    UPDATE("update","更新"),
    DELETE("delete","删除")
    ;

    private String type;
    private String desc;

    OperationTypeEnum(String type,String desc) {
        this.desc = desc;
        this.type = type;
    }

    public String getType() {
        return type;
    }

    public String getDesc() {
        return desc;
    }

    public static OperationTypeEnum getEnumForType(String type){
        Optional<OperationTypeEnum> optional = Arrays.stream(values()).filter(e -> e.type.equalsIgnoreCase(type)).findFirst();
        if(optional.isPresent()){
            return optional.get();
        }
        return null;
    }
}
